import 'package:flutter_cache_manager/flutter_cache_manager.dart';

class GTCacheManager {
  static CacheManager shortStalePeriod = CacheManager(
    Config('gt_short_stale_period', stalePeriod: const Duration(days: 3)),
  );

  static CacheManager longStalePeriod = CacheManager(
    Config('gt_long_stale_period', stalePeriod: const Duration(days: 90)),
  );

  static BaseCacheManager? getCacheManager(GTImageCacheStalePeriod? stalePeriod) {
    if (stalePeriod == null) {
      return null;
    }
    switch (stalePeriod) {
      case GTImageCacheStalePeriod.short:
        return shortStalePeriod;
      case GTImageCacheStalePeriod.normal:
        return null;
      case GTImageCacheStalePeriod.long:
        return longStalePeriod;
    }
  }
}

enum GTImageCacheStalePeriod {
  short,  // 3天过期
  normal, // 默认过期时间（1个月）
  long,   // 90天过期
}
